package cc.SSM.exceptions;

/**
 * Created by rongmc on 16/3/23.
 * xxx+xx+xxx (错误类型+业务类型+错误码)
 * 例如:500+00+001表示:
 * 500服务器端异常+01用户业务+001错误类型
 */
public enum AppServerExceptionEnum {

    APPKEY_ERROR(Long.valueOf(50002009), "AppKey不正确");

    private Long code;
    private String description;

    private AppServerExceptionEnum(Long code, String description) {
        this.code = code;
        this.description = description;
    }

    public static AppServerExceptionEnum get(Long code) {
        if(code == null) {
            return null;
        } else {
            AppServerExceptionEnum[] arr$ = values();
            int len$ = arr$.length;

            for(int i$ = 0; i$ < len$; ++i$) {
                AppServerExceptionEnum appResultCodeEnum = arr$[i$];
                if(appResultCodeEnum.getCode().equals(code)) {
                    return appResultCodeEnum;
                }
            }

            return null;
        }
    }

    public static boolean is(AppServerExceptionEnum appResultCodeEnum, Long code) {
        return appResultCodeEnum != null && code != null?appResultCodeEnum.getCode().equals(code):false;
    }

    public Long getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }
}
